<template>
  <div class="box">
    <div class="top">
      <p class="title">实时游客统计</p>
      <p class="bg"></p>
      <p class="right">
        可预约总量
        <span>9999</span>
        人
      </p>
    </div>
    <div class="number">
      <span v-for="(item, index) in people" :key="index">{{ item }}</span>
    </div>
    <div class="charts" ref="charts"></div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import * as echarts from 'echarts'
//引入水球图
import 'echarts-liquidfill'
let people = ref('2159952')
//获取节点
let charts = ref()
onMounted(() => {
  //获取echarts类的实例
  let mycharts = echarts.init(charts.value)
  //设置实例的配置项
  mycharts.setOption({
    // title: {
    //     text: '水球图'
    // },
    //x轴|y轴
    xAxis: {},
    yAxis: {},
    //选择图形图标
    series: {
      type: 'liquidFill', //图类型
      data: [0.6, 0.4, 0.2], //展示的数据
      color: [
        {
          type: 'linear',
          x: 0,
          y: 0,
          x2: 0,
          y2: 1,
          colorStops: [
            {
              offset: 0,
              color: '#20d6ba', // 0% 处的颜色
            },
            {
              offset: 1,
              color: '#1dc2bc', // 100% 处的颜色
            },
          ],
          global: false, // 缺省为 false
        },
        {
          type: 'linear',
          x: 0,
          y: 0,
          x2: 0,
          y2: 1,
          colorStops: [
            {
              offset: 0,
              color: '#1dc2bc', // 0% 处的颜色
            },
            {
              offset: 1,
              color: '#17a6bb', // 100% 处的颜色
            },
          ],
          global: false, // 缺省为 false
        },
        {
          type: 'linear',
          x: 0,
          y: 0,
          x2: 0,
          y2: 1,
          colorStops: [
            {
              offset: 0,
              color: '#18a9bb', // 0% 处的颜色
            },
            {
              offset: 1,
              color: '#1a9bbb', // 100% 处的颜色
            },
          ],
          global: false, // 缺省为 false
        },
      ],
      backgroundStyle: {
        color: '#0b2346',
        borderColor: '#21d2df',
        borderWidth: 1,
        shadowColor: 'rgba(33,210,223, 0.4)',
        shadowBlur: 20,
      },
      radius: '70%',
      waveAnimation: true, //是否开启动画
      animationDuration: 3, //动画时间
      animationDurationUpdate: 0, //动画时长更新
      outline: {
        show: true,
        borderDistance: 8,
        itemStyle: {
          color: '#7dbbe2',
          borderColor: '#21d2df',
          borderWidth: 5,
          shadowBlur: 20,
          shadowColor: '#21d2df',
        },
      },
    },
    // 布局
    grid: {
      left: 0,
      right: 0,
      top: 0,
      bottom: 0,
    },
  })
})
</script>

<style scoped lang="scss">
.box {
  background: url(../../images/dataScreen-main-lb.png) no-repeat;
  background-size: 100% 100%;
  margin-top: 10px;

  .top {
    .title {
      color: white;
      font-size: 20px;
    }

    .bg {
      width: 68px;
      height: 7px;
      background: url(../../images/dataScreen-title.png) no-repeat;
      background-size: 100% 100%;
      margin-top: 10px;
    }

    .right {
      float: right;
      color: white;
      font-size: 20px;

      span {
        color: yellowgreen;
      }
    }
  }

  .number {
    padding: 10px;
    margin-top: 40px;
    display: flex;

    span {
      flex: 1;
      height: 97px;
      text-align: center;
      line-height: 97px;
      background: url(../../images/total.png) no-repeat;
      background-size: 100% 100%;
      color: #29fcff;
    }
  }

  .charts {
    width: 100%;
    height: 200px;
  }
}
</style>
